<script>
$(document).ready(function(){
    var uceniks = $('.image_upload');
    $.each(uceniks, function(i,n){
    new AjaxUpload('#' + n.id, {action: '/skola.php/ucenik/uploadImage/id/' + n.id, autoSubmit: true, onComplete: function(file, response) { $('#' + n.id).html(response);}});
    });
});
</script>

<div>
<table cellpadding='0' cellspacing='0' style='padding: 5px; border: 1px solid #000;'>
      <?php
      $i = 0;
      foreach($uceniks as $ucenik)
      {
          if(($i++ % 8) == 0)
            echo "<tr>"?>
        <td style="text-align:center;font-size: 10px;">
          <div class="image_upload" id="uc_<?php echo $ucenik->getId() ?>">
            <?php echo Functions::image($ucenik->getId(), $ucenik->getColumn('Pol')); ?>
          </div>
          <?php echo mb_substr($ucenik->joinIme(), 0, 17, 'utf-8'); ?>
        </td>
          <?php
          if(($i % 8) == 0)
            echo "</tr>";
      }
      if(($i % 8) != 0)
            echo "</tr>";
           ?>
</table>
</div>